package com.example.uilearning;

import java.util.List;

import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.widget.Button;
import android.widget.Toast;

public class PreferenceActivityTest extends PreferenceActivity {

	@Override
	public void onBuildHeaders(List<Header> target) {
		// 该方法用于该界面设置一个标题按钮
		super.onBuildHeaders(target);
		loadHeadersFromResource(R.layout.preference_headers, target);

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		if (hasHeaders()) {
			Button button = new Button(this);
			button.setText("设置操作");
			setListFooter(button);
		}
		
	}

	public static class Prefs1Fragment extends PreferenceFragment {

		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			addPreferencesFromResource(R.xml.preferences);
		}
        
	}

	public static class Prefs2Fragment extends PreferenceFragment {

		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			addPreferencesFromResource(R.xml.display_prefs);
			//获取传入该Fragment的参数
			String website=getArguments().getString("website");
			Toast.makeText(getActivity(), "网站域名是："+website,Toast.LENGTH_LONG).show();
		}

	}

}
